package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.LotteryWinningLimit;
import com.jic.market.mapper.LotteryWinningLimitMapper;
import com.jic.market.service.LotteryWinningLimitService;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.Page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 抽奖活动用户限制记录表
 * @author : 
 * @email : 
 * @since : 2020-04-10 08:13:44
 * @version : v1.0.0
 */
@Service
public class LotteryWinningLimitServiceImpl implements LotteryWinningLimitService{

    @Autowired
    private LotteryWinningLimitMapper lotteryWinningLimitMapper;

    @Override
    public long insert(LotteryWinningLimit lotteryWinningLimit) {
        long flag = lotteryWinningLimitMapper.insert(lotteryWinningLimit);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return lotteryWinningLimitMapper.delete(id);
    }

    @Override
    public long update(LotteryWinningLimit lotteryWinningLimit) {
        return lotteryWinningLimitMapper.update(lotteryWinningLimit);
    }

    @Override
    public LotteryWinningLimit queryByPrimaryKey(Long id){
        return lotteryWinningLimitMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<LotteryWinningLimit> query(LotteryWinningLimit lotteryWinningLimit){
        return lotteryWinningLimitMapper.query(lotteryWinningLimit);
    }

    @Override
    public PageResult<LotteryWinningLimit> queryPage(LotteryWinningLimit lotteryWinningLimit, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<LotteryWinningLimit> list = lotteryWinningLimitMapper.queryPage(startIndex, pageQuery.getLimit(), lotteryWinningLimit);
        long count = lotteryWinningLimitMapper.queryPageCount(lotteryWinningLimit);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}